package com.zgscwjm.taobaphelper.ui;

import android.os.Message;

import com.zgscwjm.taobaphelper.UpdateActivity;
import com.zgscwjm.taobaphelper.exutils.StringUtils;
import com.zgscwjm.taobaphelper.xp.FileManager;

import java.io.File;

/**
 * Created by fukunaka on 2017/3/14.
 */

public class al extends Thread {
    final UpdateActivity updateActivity ; //原变量d
    Message msg; //原变量  a
    String b= StringUtils.EMPTY;
    String c= FileManager.ConfigDownPath;
    al(UpdateActivity updateActivity,String str1,String str2){
        this.updateActivity=updateActivity;
        msg=updateActivity.handler.obtainMessage();
        this.b=str1;
        this.c=str2;
    }

    @Override
    public void run() {
        super.run();
        this.msg.what=503;
        if (this.c.contains("taobao"))
        {
            this.msg.what=501;
        }
        if (this.c.contains("sogou"))
        {
            this.msg.what=5031;
        }
        try {
            File file=new File(FileManager.downloadDirPath);
            if (!file.exists())
            {
                file.mkdirs();
            }
        file=new File(this.c);
            if (!file.exists())
            {
                file.createNewFile();
            }
            if (this.updateActivity.a(this.b,file)<=0)
            {
                this.msg.what=502;
                if (this.c.contains("taobao"))
                {
                    this.msg.what=500;
                }
                if (this.c.contains("sogou"))
                {
                    this.msg.what=5021;
                }
            }
            this.updateActivity.handler.sendMessage(this.msg);
        }
        catch (Exception e)
        {
          e.printStackTrace();
            this.msg.what=502;
            if (this.c.contains("taobao"))
            {
                this.msg.what=500;
            }
            if (this.c.contains("sogou"))
            {
                this.msg.what=5021;
            }
            this.updateActivity.handler.sendMessage(this.msg);
        }

    }
}
